package cn.edu.zafu.bigdata.x.wgj.f;

public class DivisionExceptionHandling {
    public static int divide(int a,int b){
        if(b==0){
            throw new ArithmeticException("除数不能为零");
        }
        return a/b;
    }
    public static void main(String[] args){
        int a=10;
        int b=0;
        try{
            int result=divide(a,b);
            System.out.println("除法结果："+result);
        }catch (ArithmeticException e){
            System.out.println("捕获到算数异常："+e.getMessage());
        }
    }
}
